// 当前模块：api统一管理
import requests from "@/api/ajax";
import mockAjax from "@/api/mockAjax"
/** 
 * 三级联动接口 
 * /api/product/getBaseCategoryList 请求方式:GET
 * */ 
export const reqCategoryList = (
    ()=>requests({
        url:'/product/getBaseCategoryList',
        method:'get',
    })
    );

    // banner数据：mock模拟数据接口（服务器会进行拦截）
export const reqBannerList = ()=>mockAjax.get('/banner')

    // floor数据：mock模拟数据接口（服务器会进行拦截）
export const reqFloorList = (
    ()=>mockAjax({
        url:'/floor',
        method:'get'
    }))    
    
    // search数据：接口获取(post)
export const reqSearchList = (param)=>requests({
    url:'/list',
    method:'post',
    data:param
})    

// 商品详情：请求地址/api/item/{ goodsId }   请求方式GET
export const reqGoodsInfo = (
    (goodsId)=>requests({
       url:`/item/${goodsId}`,
       method:'get'  
    })
)

/**添加到购物车：
 * 请求地址/api/cart/addToCart/{ goodsId }/{ goodsNum }
 * 请求方式POST  (在请求头中需要加入UUID的标识;请求头的名称叫userTempId)
 * */ 
export const reqAddOrUpdateShopCart = (
    (goodsId,goodsNum)=>requests({
        url:`/cart/addToCart/${goodsId}/${goodsNum}`,
        method:'post',
    })
)

// 获取购物车列表数据
// url:/api/cart/cartList  methods；get 无参数
export const reqCartList = (
    ()=>requests({
        url:'/cart/cartList',
        method:'get'
    })
)

// 删除购物车商品
// 请求地址：/api/cart/deleteCart/{skuId}  请求方式：delete
export const reqDeleteCart = (
    (goodsId)=>requests({
        url:`/cart/deleteCart/${goodsId}`,
        method:'delete'
    })
)

// 切换商品选中状态
// 请求地址：/api/cart/checkCart/{skuID}/{isChecked}  请求方式：get
export const reqUpdateChecked = (
    (goodsId,isChecked)=>requests({
        url:`/cart/checkCart/${goodsId}/${isChecked}` ,
        method:'get'
    })
)

//验证码请求接口
// 请求地址:user/passport/sendCode/phone method:get
export  const reqGetUserCode = (
    (phone)=>requests({
       url:`/user/passport/sendCode/${phone}`,
       method:'get' 
    })
)

// 注册接口
//请求地址:/api/user/passport/register  请求方式:POST
export const reqUserRegister = (
    (data)=>requests({
        url:`/user/passport/register/`,
        data,
        method:'post'
    })
)

// 登录接口
//请求地址:/api/user/passport/login  请求方式:POST
export const reqUserLogin = (
    (data)=>requests({
        url:`/user/passport/login`,
        data,
        method:'post'
    })
)

// 登录获取用户信息
// 请求地址：/api/user/passport/auth/getUserInfo 请求方式：GET
export const reqUserInfo = (
    ()=>requests({
        url:"/user/passport/auth/getUserInfo",
        method:'get'
    })
)

// 退出登录接口
// 请求地址：/api/user/passport/logout 请求方式：GET
export const reqUserLogout = (
    ()=>requests({
        url:"/user/passport/logout",
        method:'get'
    })
)

// 订单交易页
// 请求地址：/api/order/auth/trade  请求方式：GET
export const reqTradePage = (
    ()=>requests({
        url:"/order/auth/trade",
        method:'get'
    })
)

// mock接口数据
// 请求地址：/mock/address
export const reqMockAddress = (
    ()=>mockAjax({
        url:"/myaddress",
        method:"get"
    }
))

// 提交订单
// url:/api/order/auth/submitOrder?tradeNo={tradeNo}  method:post
export const reqSubmitOrder = (
    (tradeNo,data)=> requests({
        url:`/order/auth/submitOrder?tradeNo=${tradeNo}`,
        data,
        method:"post"
    })
) 

//获取订单支付信息
// url:/api/payment/weixin/createNative/{orderId}  method:get
export const reqOrderPay = (
    (orderId)=>requests({
        url:`/payment/weixin/createNative/${orderId}`,
        method:'get'
    })
)
//获取订单支付状态
// url:/api/payment/weixin/queryPayStatus/{orderId} method:get
export const reqPayStatus = (
    (orderId)=>requests({
        url:`/payment/weixin/queryPayStatus/${orderId}`,
        method:'get'
    })
)

//获取订单支付状态
// url:/api/order/auth/{page}/{limit} method:get
export const reqMyOrderList = (
    (page,limit)=>requests({
        url:`/order/auth/${page}/${limit}`,
        method:'get'
    })
)








